package com.weiz.designpatterns.memento;

public class TextEditor {
    private StringBuilder text;
    public TextEditor() {
        this.text = new StringBuilder();
    }
    public void appendText(String textToAdd) {
        text.append(textToAdd);
    }
    public String getText() {
        return text.toString();
    }
    public TextEditorMemento save() {
        return new TextEditorMemento(text.toString());
    }
    public void restore(TextEditorMemento memento) {
        this.text = new StringBuilder(memento.getText());
    }
}